package com.test.thread;



public class AlwaysEven {
	private long i = 0;

	public void next() {
		i++;
		i++;
	}

	public long getEven() {
		return i;
	}

	public static void main(String[] args) throws InterruptedException {

		final AlwaysEven ae = new AlwaysEven();
		new Thread("Watcher") {
			public void run() {
				while (true) {
					long e = ae.getEven();
					if (e % 2 != 0) {
						System.out.println(e + " is not an even.");
						System.exit(0);
					}
					System.out.println("Current value is:" + e);
					try {
						Thread.sleep(11);
					} catch (InterruptedException e1) {
						e1.printStackTrace();
					}
				}
			}
		}.start();

		while (true) {
			ae.next();
			Thread.sleep(10);
		}

	}

}
